package albert3d.gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class Miniatura extends JLabel {
    
    public Miniatura(String sciezkaDoPliku, int numer) {       
        
        if (sciezkaDoPliku.equals("brak")) {
            sciezkaDoPliku = "./gfx/noimage.png";
        }
        
        ImageIcon ikona_tmp = new ImageIcon(sciezkaDoPliku);
        int szerokosc = ikona_tmp.getIconWidth();
        int wysokosc = ikona_tmp.getIconHeight();
        
        int nowaSzerokosc = (szerokosc * 150) / wysokosc;  
        		
        Image image = new ImageIcon(sciezkaDoPliku).getImage().getScaledInstance(nowaSzerokosc, 150, Image.SCALE_SMOOTH);
        final ImageIcon ikona = new ImageIcon(image);
        
        this.setIcon(ikona);
        this.setBackground(Color.DARK_GRAY);        
        this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 15));
        this.setForeground(Color.WHITE);
        this.setFont(new Font("Tahoma", 1, 16));
        this.setText(Integer.toString(numer));
        
        
    }   
    
}
